<template>
	<view style="padding: 20rpx;">
		<view style="margin-bottom: 20rpx;background-color: #FFFFFF;border-radius: 20rpx;padding: 20rpx;">
			<view style="font-size: 36rpx;font-weight: 900;">我的社团</view>
			<club-list v-if="adminClubList.length!=0" :clubList="adminClubList"></club-list>
			<view v-else style="margin-top: 20rpx;text-align: center;">
				---您未管理社团---
			</view>
		</view>
		<view style="background-color: #FFFFFF;border-radius: 20rpx;padding: 20rpx;">
			<view style="font-size: 36rpx;font-weight: 900;">我加入的社团</view>
			<club-list v-if="myClubList.length!=0" :clubList="myClubList"></club-list>
			<view v-else style="margin-top: 20rpx;text-align: center;">
				---您未加入社团---
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex'
	import clubList from "../../../components/club/club-list.vue";
	export default {
		computed: mapState(['isLogin', 'loginUserInfo']),
		components: {clubList},
		data() {
			return {
				myClubList:[],
				adminClubList:[]
			}
		},
		onShow(){
			this.loadMyClubList();
			this.loadMyAdminClubList()
		},
		methods: {
			loadMyClubList(){
				var that = this
				uni.request({
					url: that.url.club.getOneUserClubs+"/"+that.loginUserInfo.id,
					method: 'GET',
					header: {},
					success: (res) => {
						console.log(res)
						that.myClubList = res.data.clubList
						console.log(that.myClubList)
					},
					fail: (res) => {
						console.log(res)
					}
				});
			},
			loadMyAdminClubList(){
				var that = this
				console.log(that.url.club.getOneUserAdminClubs+"/"+that.loginUserInfo.id)
				uni.request({
					url: that.url.club.getOneUserAdminClubs+"/"+that.loginUserInfo.id,
					method: 'GET',
					header: {},
					success: (res) => {
						console.log(res)
						that.adminClubList = res.data.adminClubList
						console.log(that.adminClubList)
					},
					fail: (res) => {
						console.log(res)
					}
				});
			}
		}
	}
</script>

<style>

</style>
